﻿<template>
  <a-modal
    :title="title"
    width="40%"
    :visible="visible"
    :confirmLoading="loading"
    @ok="handleSubmit"
    @cancel="()=>{this.visible=false}"
  >
    <a-spin :spinning="loading">
      <a-form-model ref="form" :model="entity" :rules="rules" v-bind="layout">
        <a-form-model-item label="主表标识" prop="iID">
          <a-input v-model="entity.iID" autocomplete="off" placeholder="主表标识" />
        </a-form-model-item>
        <a-form-model-item label="子表标识" prop="ID">
          <a-input v-model="entity.ID" autocomplete="off" placeholder="子表标识" />
        </a-form-model-item>
        <a-form-model-item label="款项类型号" prop="iType">
          <a-input v-model="entity.iType" autocomplete="off" placeholder="款项类型号" />
        </a-form-model-item>
        <a-form-model-item label="预收预付标志" prop="bPrePay">
          <a-input v-model="entity.bPrePay" autocomplete="off" placeholder="预收预付标志" />
        </a-form-model-item>
        <a-form-model-item label="客户或供应商编码" prop="cCusVen">
          <a-input v-model="entity.cCusVen" autocomplete="off" placeholder="客户或供应商编码" />
        </a-form-model-item>
        <a-form-model-item label="原币金额" prop="iAmt_f">
          <a-input v-model="entity.iAmt_f" autocomplete="off" placeholder="原币金额" />
        </a-form-model-item>
        <a-form-model-item label="本币金额" prop="iAmt">
          <a-input v-model="entity.iAmt" autocomplete="off" placeholder="本币金额" />
        </a-form-model-item>
        <a-form-model-item label="原币余额" prop="iRAmt_f">
          <a-input v-model="entity.iRAmt_f" autocomplete="off" placeholder="原币余额" />
        </a-form-model-item>
        <a-form-model-item label="本币余额" prop="iRAmt">
          <a-input v-model="entity.iRAmt" autocomplete="off" placeholder="本币余额" />
        </a-form-model-item>
        <a-form-model-item label="科目编码" prop="cKm">
          <a-input v-model="entity.cKm" autocomplete="off" placeholder="科目编码" />
        </a-form-model-item>
        <a-form-model-item label="项目大类编码" prop="cXmClass">
          <a-input v-model="entity.cXmClass" autocomplete="off" placeholder="项目大类编码" />
        </a-form-model-item>
        <a-form-model-item label="项目编码" prop="cXm">
          <a-input v-model="entity.cXm" autocomplete="off" placeholder="项目编码" />
        </a-form-model-item>
        <a-form-model-item label="部门编码" prop="cDepCode">
          <a-input v-model="entity.cDepCode" autocomplete="off" placeholder="部门编码" />
        </a-form-model-item>
        <a-form-model-item label="业务员编码" prop="cPersonCode">
          <a-input v-model="entity.cPersonCode" autocomplete="off" placeholder="业务员编码" />
        </a-form-model-item>
        <a-form-model-item label="订单号" prop="cOrderID">
          <a-input v-model="entity.cOrderID" autocomplete="off" placeholder="订单号" />
        </a-form-model-item>
        <a-form-model-item label="项目名称" prop="cItemName">
          <a-input v-model="entity.cItemName" autocomplete="off" placeholder="项目名称" />
        </a-form-model-item>
        <a-form-model-item label="合同类型" prop="cConType">
          <a-input v-model="entity.cConType" autocomplete="off" placeholder="合同类型" />
        </a-form-model-item>
        <a-form-model-item label="合同号" prop="cConID">
          <a-input v-model="entity.cConID" autocomplete="off" placeholder="合同号" />
        </a-form-model-item>
        <a-form-model-item label="数量" prop="iAmt_s">
          <a-input v-model="entity.iAmt_s" autocomplete="off" placeholder="数量" />
        </a-form-model-item>
        <a-form-model-item label="数量余额" prop="iRAmt_s">
          <a-input v-model="entity.iRAmt_s" autocomplete="off" placeholder="数量余额" />
        </a-form-model-item>
        <a-form-model-item label="来源" prop="iOrderType">
          <a-input v-model="entity.iOrderType" autocomplete="off" placeholder="来源" />
        </a-form-model-item>
        <a-form-model-item label="发货单" prop="cDLCode">
          <a-input v-model="entity.cDLCode" autocomplete="off" placeholder="发货单" />
        </a-form-model-item>
        <a-form-model-item label="信用证项目" prop="ccItemCode">
          <a-input v-model="entity.ccItemCode" autocomplete="off" placeholder="信用证项目" />
        </a-form-model-item>
        <a-form-model-item label="登记标志" prop="RegisterFlag">
          <a-input v-model="entity.RegisterFlag" autocomplete="off" placeholder="登记标志" />
        </a-form-model-item>
        <a-form-model-item label="自定义项22" prop="cDefine22">
          <a-input v-model="entity.cDefine22" autocomplete="off" placeholder="自定义项22" />
        </a-form-model-item>
        <a-form-model-item label="自定义项23" prop="cDefine23">
          <a-input v-model="entity.cDefine23" autocomplete="off" placeholder="自定义项23" />
        </a-form-model-item>
        <a-form-model-item label="自定义项24" prop="cDefine24">
          <a-input v-model="entity.cDefine24" autocomplete="off" placeholder="自定义项24" />
        </a-form-model-item>
        <a-form-model-item label="自定义项25" prop="cDefine25">
          <a-input v-model="entity.cDefine25" autocomplete="off" placeholder="自定义项25" />
        </a-form-model-item>
        <a-form-model-item label="自定义项26" prop="cDefine26">
          <a-input v-model="entity.cDefine26" autocomplete="off" placeholder="自定义项26" />
        </a-form-model-item>
        <a-form-model-item label="自定义项27" prop="cDefine27">
          <a-input v-model="entity.cDefine27" autocomplete="off" placeholder="自定义项27" />
        </a-form-model-item>
        <a-form-model-item label="自定义项28" prop="cDefine28">
          <a-input v-model="entity.cDefine28" autocomplete="off" placeholder="自定义项28" />
        </a-form-model-item>
        <a-form-model-item label="自定义项29" prop="cDefine29">
          <a-input v-model="entity.cDefine29" autocomplete="off" placeholder="自定义项29" />
        </a-form-model-item>
        <a-form-model-item label="自定义项30" prop="cDefine30">
          <a-input v-model="entity.cDefine30" autocomplete="off" placeholder="自定义项30" />
        </a-form-model-item>
        <a-form-model-item label="自定义项31" prop="cDefine31">
          <a-input v-model="entity.cDefine31" autocomplete="off" placeholder="自定义项31" />
        </a-form-model-item>
        <a-form-model-item label="自定义项32" prop="cDefine32">
          <a-input v-model="entity.cDefine32" autocomplete="off" placeholder="自定义项32" />
        </a-form-model-item>
        <a-form-model-item label="自定义项33" prop="cDefine33">
          <a-input v-model="entity.cDefine33" autocomplete="off" placeholder="自定义项33" />
        </a-form-model-item>
        <a-form-model-item label="自定义项34" prop="cDefine34">
          <a-input v-model="entity.cDefine34" autocomplete="off" placeholder="自定义项34" />
        </a-form-model-item>
        <a-form-model-item label="自定义项35" prop="cDefine35">
          <a-input v-model="entity.cDefine35" autocomplete="off" placeholder="自定义项35" />
        </a-form-model-item>
        <a-form-model-item label="自定义项36" prop="cDefine36">
          <a-input v-model="entity.cDefine36" autocomplete="off" placeholder="自定义项36" />
        </a-form-model-item>
        <a-form-model-item label="自定义项37" prop="cDefine37">
          <a-input v-model="entity.cDefine37" autocomplete="off" placeholder="自定义项37" />
        </a-form-model-item>
        <a-form-model-item label="合同阶段" prop="cStageCode">
          <a-input v-model="entity.cStageCode" autocomplete="off" placeholder="合同阶段" />
        </a-form-model-item>
        <a-form-model-item label="付款申请单号" prop="cCoVouchID">
          <a-input v-model="entity.cCoVouchID" autocomplete="off" placeholder="付款申请单号" />
        </a-form-model-item>
        <a-form-model-item label="合同执行单号" prop="cExecID">
          <a-input v-model="entity.cExecID" autocomplete="off" placeholder="合同执行单号" />
        </a-form-model-item>
        <a-form-model-item label="表体备注" prop="cMemo">
          <a-input v-model="entity.cMemo" autocomplete="off" placeholder="表体备注" />
        </a-form-model-item>
        <a-form-model-item label="对应来源单据ID" prop="iSrcClosesID">
          <a-input v-model="entity.iSrcClosesID" autocomplete="off" placeholder="对应来源单据ID" />
        </a-form-model-item>
        <a-form-model-item label="费用结算金额" prop="ifaresettled_f">
          <a-input v-model="entity.ifaresettled_f" autocomplete="off" placeholder="费用结算金额" />
        </a-form-model-item>
        <a-form-model-item label="电商订单号" prop="cEBOrderCode">
          <a-input v-model="entity.cEBOrderCode" autocomplete="off" placeholder="电商订单号" />
        </a-form-model-item>
      </a-form-model>
    </a-spin>
  </a-modal>
</template>

<script>
export default {
  props: {
    parentObj: Object
  },
  data () {
    return {
      layout: {
        labelCol: { span: 5 },
        wrapperCol: { span: 18 }
      },
      visible: false,
      loading: false,
      entity: {},
      rules: {},
      title: ''
    }
  },
  methods: {
    init () {
      this.visible = true
      this.entity = {}
      this.$nextTick(() => {
        this.$refs['form'].clearValidate()
      })
    },
    openForm (id, title) {
      this.init()
      this.title = title
      if (id) {
        this.loading = true
        this.$http.post('/OrderManagement/Ap_CloseBills/GetTheData', { id: id }).then(resJson => {
          this.loading = false

          this.entity = resJson.Data
        })
      }
    },
    handleSubmit () {
      this.$refs['form'].validate(valid => {
        if (!valid) {
          return
        }
        this.loading = true
        this.$http.post('/OrderManagement/Ap_CloseBills/SaveData', this.entity).then(resJson => {
          this.loading = false

          if (resJson.Success) {
            this.$message.success('操作成功!')
            this.visible = false

            this.parentObj.getDataList()
          } else {
            this.$message.error(resJson.Msg)
          }
        })
      })
    }
  }
}
</script>
